package com.nexus.service.sys.service;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nexus.core.exception.ServiceException;
import com.nexus.core.service.BaseService;
import com.nexus.core.sys.dto.SysDictValueDTO;
import com.nexus.core.sys.dto.SysDictValueDTO;
import com.nexus.core.sys.entity.SysDictValue;
import com.nexus.service.sys.mapper.SysDictValueMapper;
import com.nexus.service.sys.service.mapstruct.SysDictValueWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 系统字典ValueService
 *
 * @author 路正宁
 * @version 2023-03-15
 */

@Service
@Transactional(rollbackFor = {ServiceException.class,Exception.class, RuntimeException.class})
public class SysDictValueService extends BaseService<SysDictValueMapper, SysDictValue, SysDictValueDTO,SysDictValueWrapper> {

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    public SysDictValueDTO findById(String id) {
        return baseMapper.findById(id);
    }

    /**
     * 自定义分页检索
     *
     * @param page
     * @param queryWrapper
     * @return
     */
    public IPage<SysDictValueDTO> findPage(Page<SysDictValueDTO> page, QueryWrapper queryWrapper) {
        queryWrapper.eq("a.deleted", 0); // 排除已经删除
        return baseMapper.findList(page, queryWrapper);
    }

}
